package com.screen.screendisplay.controller;

import com.screen.screendisplay.common.pojo.ApiResponse;
import com.screen.screendisplay.service.coal.CoalProdoperOutputService;
import com.screen.screendisplay.service.coal.CoalProdoperSalesService;
import com.screen.screendisplay.service.coal.CoalProdoperStockService;
import com.screen.screendisplay.service.dryport.DryportProdoperGoodsSendService;
import com.screen.screendisplay.service.dryport.DryportProdoperPortGatherService;
import com.screen.screendisplay.service.dryport.DryportProdoperTurnoverService;
import com.screen.screendisplay.service.electric.ElectricProdoperFuelService;
import com.screen.screendisplay.service.electric.ElectricProdoperPowerGeneralService;
import com.screen.screendisplay.service.wholeproduct.IWholeNeInstallVolumeService;
import com.screen.screendisplay.service.wholeproduct.IWholeNeRealTimePowerService;
import com.screen.screendisplay.service.wholeproduct.IWholeNePowerGenerationService;
import com.screen.screendisplay.service.wholeproduct.IWholeAlProductionService;
import com.screen.screendisplay.service.wholeproduct.IWholeAlSalesService;
import com.screen.screendisplay.service.wholeproduct.WholeOverviewItemService;
import com.screen.screendisplay.service.wholeproduct.IWholeNeProdEfficService;
import com.screen.screendisplay.vo.wholeproduct.AluminumProductionEfficiencyVO;
import com.screen.screendisplay.vo.wholeproduct.AluminumProductionVO;
import com.screen.screendisplay.vo.wholeproduct.AluminumSalesVO;
import com.screen.screendisplay.vo.wholeproduct.AnnualActualSalesVO;
import com.screen.screendisplay.vo.wholeproduct.AnnualPowerGenerationVO;
import com.screen.screendisplay.vo.wholeproduct.AnnualSalesCompletionRateVO;
import com.screen.screendisplay.vo.wholeproduct.AnnualSalesCompletionVO;
import com.screen.screendisplay.vo.wholeproduct.AnnualStockVO;
import com.screen.screendisplay.vo.wholeproduct.CoalOutputCompletionVO;
import com.screen.screendisplay.vo.wholeproduct.CoalStockDetailVO;
import com.screen.screendisplay.vo.wholeproduct.CoalStockYoyVO;
import com.screen.screendisplay.vo.wholeproduct.FuelConsumptionVO;
import com.screen.screendisplay.vo.wholeproduct.GoodsTurnoverVO;
import com.screen.screendisplay.vo.wholeproduct.MonthlyOutputCompletionVO;
import com.screen.screendisplay.vo.wholeproduct.NewEnergyInstallVolumeVO;
import com.screen.screendisplay.vo.wholeproduct.NewEnergyPowerGenerationVO;
import com.screen.screendisplay.vo.wholeproduct.NewEnergyRealTimePowerVO;
import com.screen.screendisplay.vo.wholeproduct.PortGatheringVO;
import com.screen.screendisplay.vo.wholeproduct.RailwayGoodsSendVO;
import com.screen.screendisplay.vo.wholeproduct.WholeProductOverviewVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 能源消费表 前端控制器
 * </p>
 *
 * @author xuesong
 * @since 2025-08-23
 */
@Tag(name = "全产业一体化", description = "全产业一体化")
@RestController
@RequestMapping("/wholeproduct")
public class WholeProductController {

    private final CoalProdoperOutputService coalProdoperOutputService;
    private final CoalProdoperSalesService coalProdoperSalesService;
    private final CoalProdoperStockService coalProdoperStockService;
    private final DryportProdoperGoodsSendService dryportProdoperGoodsSendService;
    private final DryportProdoperTurnoverService dryportProdoperTurnoverService;
    private final DryportProdoperPortGatherService dryportProdoperPortGatherService;
    private final ElectricProdoperPowerGeneralService electricProdoperPowerGeneralService;
    private final ElectricProdoperFuelService electricProdoperFuelService;
    private final IWholeNeInstallVolumeService wholeNeInstallVolumeService;
    private final IWholeNeRealTimePowerService wholeNeRealTimePowerService;
    private final IWholeNePowerGenerationService wholeNePowerGenerationService;
    private final IWholeAlProductionService wholeAlProductionService;
    private final IWholeAlSalesService wholeAlSalesService;
    private final WholeOverviewItemService wholeOverviewItemService;
    private final IWholeNeProdEfficService wholeNeProdEfficService;

    public WholeProductController(CoalProdoperOutputService coalProdoperOutputService,
                                  CoalProdoperSalesService coalProdoperSalesService,
                                  CoalProdoperStockService coalProdoperStockService,
                                  DryportProdoperGoodsSendService dryportProdoperGoodsSendService,
                                  DryportProdoperTurnoverService dryportProdoperTurnoverService,
                                  DryportProdoperPortGatherService dryportProdoperPortGatherService,
                                  ElectricProdoperPowerGeneralService electricProdoperPowerGeneralService,
                                  ElectricProdoperFuelService electricProdoperFuelService,
                                  IWholeNeInstallVolumeService wholeNeInstallVolumeService,
                                  IWholeNeRealTimePowerService wholeNeRealTimePowerService,
                                  IWholeNePowerGenerationService wholeNePowerGenerationService,
                                  IWholeAlProductionService wholeAlProductionService,
                                  IWholeAlSalesService wholeAlSalesService,
                                  WholeOverviewItemService wholeOverviewItemService,
                                  IWholeNeProdEfficService wholeNeProdEfficService) {
        this.coalProdoperOutputService = coalProdoperOutputService;
        this.coalProdoperSalesService = coalProdoperSalesService;
        this.coalProdoperStockService = coalProdoperStockService;
        this.dryportProdoperGoodsSendService = dryportProdoperGoodsSendService;
        this.dryportProdoperTurnoverService = dryportProdoperTurnoverService;
        this.dryportProdoperPortGatherService = dryportProdoperPortGatherService;
        this.electricProdoperPowerGeneralService = electricProdoperPowerGeneralService;
        this.electricProdoperFuelService = electricProdoperFuelService;
        this.wholeNeInstallVolumeService = wholeNeInstallVolumeService;
        this.wholeNeRealTimePowerService = wholeNeRealTimePowerService;
        this.wholeNePowerGenerationService = wholeNePowerGenerationService;
        this.wholeAlProductionService = wholeAlProductionService;
        this.wholeAlSalesService = wholeAlSalesService;
        this.wholeOverviewItemService = wholeOverviewItemService;
        this.wholeNeProdEfficService = wholeNeProdEfficService;
    }

    @Operation(summary = "煤炭-煤炭产量完成情况-计划原煤产量", description = "煤炭-煤炭产量完成情况-计划原煤产量")
    @GetMapping(value = "/coalOutputCompletion")
    public ApiResponse<CoalOutputCompletionVO> coalOutputCompletion(@RequestParam(value = "year", required = false) Integer year) {
        CoalOutputCompletionVO vo = coalProdoperOutputService.getCoalOutputCompletion(year);
        return ApiResponse.succeed(vo);
    }

    @Operation(summary = "煤炭-煤炭产量完成情况-实际原煤产量及原煤产量完成率",
                                                    description = "煤炭-煤炭产量完成情况-实际原煤产量及原煤产量完成率")
    @GetMapping(value = "/monthlyOutputCompletion")
    public ApiResponse<List<MonthlyOutputCompletionVO>> monthlyOutputCompletion(@RequestParam(value = "year", required = false) Integer year) {
        List<MonthlyOutputCompletionVO> list = coalProdoperOutputService.getMonthlyOutputCompletion(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "煤炭-本年度商品煤销量完成情况-煤炭计划销量", description = "煤炭-本年度商品煤销量完成情况-煤炭计划销量")
    @GetMapping(value = "/annualSalesCompletion")
    public ApiResponse<AnnualSalesCompletionVO> annualSalesCompletion(@RequestParam(value = "year", required = false) Integer year) {
        AnnualSalesCompletionVO vo = coalProdoperSalesService.getAnnualSalesCompletion(year);
        return ApiResponse.succeed(vo);
    }

    @Operation(summary = "煤炭-本年度商品煤销量完成情况-煤炭实际销量", description = "煤炭-本年度商品煤销量完成情况-煤炭实际销量")
    @GetMapping(value = "/annualActualSales")
    public ApiResponse<List<AnnualActualSalesVO>> annualActualSales(@RequestParam(value = "year", required = false) Integer year) {
        List<AnnualActualSalesVO> list = coalProdoperSalesService.getAnnualActualSales(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "煤炭-本年度商品煤销量完成情况-煤炭销量完成率", description = "煤炭-本年度商品煤销量完成情况-煤炭销量完成率")
    @GetMapping(value = "/annualSalesCompletionRate")
    public ApiResponse<List<AnnualSalesCompletionRateVO>> annualSalesCompletionRate(@RequestParam(value = "year", required = false) Integer year) {
        List<AnnualSalesCompletionRateVO> list = coalProdoperSalesService.getAnnualSalesCompletionRate(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "煤炭-煤炭库存量情况-库存量", description = "煤炭-煤炭库存量情况-库存量")
    @GetMapping(value = "/annualStock")
    public ApiResponse<List<AnnualStockVO>> annualStock(@RequestParam(value = "year", required = false) Integer year) {
        List<AnnualStockVO> list = coalProdoperStockService.getAnnualStock(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "煤炭-煤炭库存量情况-库存量环比率", description = "煤炭-煤炭库存量情况-库存量环比率")
    @GetMapping(value = "/coalStockDetail")
    public ApiResponse<CoalStockDetailVO> coalStockDetail(@RequestParam(value = "year", required = false) Integer year) {
        CoalStockDetailVO vo = coalProdoperStockService.getCoalStockDetail(year);
        return ApiResponse.succeed(vo);
    }

    @Operation(summary = "煤炭-煤炭库存量情况-库存量同比率", description = "煤炭-煤炭库存量情况-库存量同比率")
    @GetMapping(value = "/coalStockYoy")
    public ApiResponse<CoalStockYoyVO> coalStockYoy(@RequestParam(value = "year", required = false) Integer year) {
        CoalStockYoyVO vo = coalProdoperStockService.getCoalStockYoy(year);
        return ApiResponse.succeed(vo);
    }


    @Operation(summary = "路港-铁路货物发送情况", description = "路港-铁路货物发送情况")
    @GetMapping(value = "/railwayGoodsSend")
    public ApiResponse<List<RailwayGoodsSendVO>> railwayGoodsSend(@RequestParam(value = "year", required = false) Integer year) {
        List<RailwayGoodsSendVO> list = dryportProdoperGoodsSendService.getRailwayGoodsSendAnnual(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "路港-铁路货物周转量情况", description = "路港-铁路货物周转量情况")
    @GetMapping(value = "/goodsTurnover")
    public ApiResponse<List<GoodsTurnoverVO>> goodsTurnover(@RequestParam(value = "year", required = false) Integer year) {
        List<GoodsTurnoverVO> list = dryportProdoperTurnoverService.getGoodsTurnoverAnnual(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "路港-港口集港量情况", description = "路港-港口集港量情况")
    @GetMapping(value = "/portGathering")
    public ApiResponse<List<PortGatheringVO>> portGathering(@RequestParam(value = "year", required = false) Integer year) {
        List<PortGatheringVO> list = dryportProdoperPortGatherService.getAnnualPortGathering();
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "火电-发电计划完成情况", description = "火电-发电计划完成情况")
    @GetMapping(value = "/annualPowerGeneration")
    public ApiResponse<List<AnnualPowerGenerationVO>> annualPowerGeneration(@RequestParam(value = "year", required = false) Integer year) {
        List<AnnualPowerGenerationVO> list = electricProdoperPowerGeneralService.getAnnualPowerGeneration();
        return ApiResponse.succeed(list);
    }

    // @Operation(summary = "火电-供热消耗情况", description = "火电-供热消耗情况")
    // @GetMapping(value = "/m13")
    // public ApiResponse<Object> heatConsumption(@RequestParam(value = "year", required = false) Integer year) {
    //     return ApiResponse.succeed();
    // }

    @Operation(summary = "火电-燃料耗存情况", description = "火电-燃料耗存情况")
    @GetMapping(value = "/fuelConsumption")
    public ApiResponse<List<FuelConsumptionVO>> fuelConsumption(@RequestParam(value = "year", required = false) Integer year) {
        List<FuelConsumptionVO> list = electricProdoperFuelService.getAnnualFuelConsumption();
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "新能源-新能源装机容量", description = "新能源-新能源装机容量")
    @GetMapping(value = "/newEnergyInstallVolume")
    public ApiResponse<List<NewEnergyInstallVolumeVO>> newEnergyInstallVolume(@RequestParam(value = "year", required = false) Integer year) {
        List<NewEnergyInstallVolumeVO> list = wholeNeInstallVolumeService.getNewEnergyInstallVolume(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "新能源-实时功率", description = "新能源-实时功率")
    @GetMapping(value = "/newEnergyRealTimePower")
    public ApiResponse<List<NewEnergyRealTimePowerVO>> newEnergyRealTimePower(@RequestParam(value = "year", required = false) Integer year) {
        List<NewEnergyRealTimePowerVO> list = wholeNeRealTimePowerService.getNewEnergyRealTimePower(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "新能源-发电情况", description = "新能源-发电情况")
    @GetMapping(value = "/newEnergyPowerGeneration")
    public ApiResponse<NewEnergyPowerGenerationVO> newEnergyPowerGeneration(@RequestParam(value = "year", required = false) Integer year) {
        NewEnergyPowerGenerationVO vo = wholeNePowerGenerationService.getNewEnergyPowerGeneration(year);
        return ApiResponse.succeed(vo);
    }

    @Operation(summary = "铝业-生产完成情况", description = "铝业-生产完成情况")
    @GetMapping(value = "/aluminumProduction")
    public ApiResponse<List<AluminumProductionVO>> aluminumProduction(@RequestParam(value = "year", required = false) Integer year) {
        List<AluminumProductionVO> list = wholeAlProductionService.getAluminumProduction(year);
        return ApiResponse.succeed(list);
    }

    @Operation(summary = "铝业-销售完成情况", description = "铝业-销售完成情况")
    @GetMapping(value = "/aluminumSales")
    public ApiResponse<List<AluminumSalesVO>> aluminumSales(@RequestParam(value = "year", required = false) Integer year) {
        List<AluminumSalesVO> list = wholeAlSalesService.getAluminumSales(year);
        return ApiResponse.succeed(list);
    }
    
    @Operation(summary = "产业指标-产业顶部指标", description = "产业指标-产业顶部指标")
    @GetMapping(value = "/wholeProductOverview")
    public ApiResponse<WholeProductOverviewVO> wholeProductOverview(@RequestParam(value = "year", required = false) Integer year) {
        WholeProductOverviewVO vo = wholeOverviewItemService.getLatestOverview(year);
        return ApiResponse.succeed(vo);
    }

    @Operation(summary = "铝业-生产效率情况", description = "铝业-生产效率情况")
    @GetMapping(value = "/aluminumProductionEfficiency")
    public ApiResponse<AluminumProductionEfficiencyVO> aluminumProductionEfficiency(@RequestParam(value = "year", required = false) Integer year) {
        AluminumProductionEfficiencyVO vo = wholeNeProdEfficService.getLatestProductionEfficiency(year);
        return ApiResponse.succeed(vo);
    }

}
